package com.winner.monitor;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * spring监听者模式学习
 * https://www.jb51.net/article/188455.htm
 */
public class ListenerTest {

	public static void main(String[] args) {
		AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(AppConfig.class);
		// 触发了2个onApplicationEvent方法, LearnListener类里是容器初始化触发, MyListener类, 需要调用context.publishEvent(myEvent); 手动触发
		MyEvent myEvent = new MyEvent("myEvent", 9527L, "十二点了 该吃饭了~");
		context.publishEvent(myEvent);
		System.out.println("发送结束");
	}
}